﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZQNB.BaseLib.Core.Models;
using ZQNB.Common;
using ZQNB.Web.Common.Contexts;

namespace ZQNB.Web.Areas.Cloud.Controllers
{
    // 安装人员使用，不需要导航链接的后门接口
    //todo...
    public class SetupController : BaseCloudController
    {
        private readonly INbSiteContextProvider _nbSiteContextProvider;

        public SetupController(INbSiteContextProvider nbSiteContextProvider)
        {
            _nbSiteContextProvider = nbSiteContextProvider;
        }

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult AceSetting()
        {
            return View();
        }

        public ActionResult BsSetting(bool? insideContainer, string theme, string layout, bool? responsive, string returnUrl)
        {
            BsSetting bsSetting = _nbSiteContextProvider.GetBsSetting();
            if (insideContainer.HasValue)
            {
                bsSetting.InsideContainer = insideContainer.Value;
            }

            if (!string.IsNullOrWhiteSpace(theme))
            {
                bsSetting.Theme = theme;
            }


            if (!string.IsNullOrWhiteSpace(layout))
            {
                bsSetting.Layout = layout;
            }
            
            if (responsive.HasValue)
            {
                bsSetting.Responsive = responsive.Value;
            }
            
            _nbSiteContextProvider.SaveBsSetting(bsSetting);

            if (!string.IsNullOrWhiteSpace(returnUrl))
            {
                return Redirect(returnUrl);
            }
            return Json(bsSetting, JsonRequestBehavior.AllowGet);
        }
        
        ////to be delete
        //public ActionResult BsSetting(bool? insideContainer, bool? responsive, string theme)
        //{
        //    BsSetting bsSetting = _nbSiteContextProvider.GetBsSetting();
        //    if (insideContainer.HasValue)
        //    {
        //        bsSetting.InsideContainer = insideContainer.Value;
        //    }

        //    if (responsive.HasValue)
        //    {
        //        bsSetting.Responsive = responsive.Value;
        //    }

        //    if (!string.IsNullOrWhiteSpace(theme))
        //    {
        //        bsSetting.Theme = theme;
        //    }

        //    _nbSiteContextProvider.SaveBsSetting(bsSetting);
        //    return Json(bsSetting, JsonRequestBehavior.AllowGet);
        //}
    }
}